<template>
	<view style="background-color: #333333;height: 100vh;padding-top: 50rpx;">
		<view class="" style="margin-left: 35rpx;"><image :src="sharePicUrl" mode="" style="width: 95%;height: 75vh;"></image></view>
		<view class="main">
			<button open-type="share" hover-class="none" class="btn" style="background-color: #fff;"><view class="">立即分享</view></button>

			<!-- 	<view class="btn" style="background-color: #fff;" open-type="share">立即分享</view> -->

			<button type="primary" @click="bc" class="btn" style="background-color: aquamarine;color: black;">保存相册</button>
		</view>
	</view>
</template>

<script>
export default {
	data() {
		return {
			sharePicUrl: 'https://20240202xhfpeizhenxiaochengxu.rchz.top/uploads/20240312/16d6e604fdfe41ccc0d726e4bc7cf26a.png'
		};
	},
	methods: {
		onShareAppMessage(res) {
			let _this = this;

			return {
				imageUrl: _this.sharePicUrl,
				title: '分享得福利，陪诊更安心',
				path: '/pages/index/index'
			};
		},
		bc() {
			const that = this;
			uni.downloadFile({
				url: that.sharePicUrl,
				success: res => {
					if (res.statusCode === 200) {
						uni.saveImageToPhotosAlbum({
							filePath: res.tempFilePath,
							success: function() {
								uni.showToast({
									title: '保存下载成功',
									icon: 'none',
									duration: 2500
								});
							},
							fail: function() {
								uni.showToast({
									title: '保存失败，请稍后重试',
									icon: 'none',
									duration: 2500
								});
							}
						});
					} else {
						uni.showToast({
							title: '下载失败',
							icon: 'none',
							duration: 2500
						});
					}
				}
			});
		}
	}
};
</script>

<style lang="scss">
.main {
	margin-left: 35rpx;
	display: flex;
	.btn {
		margin-top: 20rpx;
		width: 320rpx;
		height: 80rpx;
		border-radius: 50rpx;
		text-align: center;
		line-height: 80rpx;
		margin-right: 40rpx;
	}
}
</style>
